package com.wang.generic;

import com.wang.collection.Student;

public class TestGeneric {
    public static void main(String[] args) {
        //使用泛型类创建对象
        MyGeneric<Student> studentMyGeneric = new MyGeneric<>();
        studentMyGeneric.t = new Student("wang",1);
        Student t = studentMyGeneric.getT();
        System.out.println(t);
        studentMyGeneric.show(new Student("wang2",2));
        /******/
        MyGeneric<Integer> myGeneric = new MyGeneric<>();
        myGeneric.t = 1;
        System.out.println(myGeneric.getT());;
        myGeneric.show(2);
        //测试泛型方法
        MyGenericMethod method = new MyGenericMethod();
        method.show("hello");//这里的泛型类型就不用传,以传递的数据类型决定
        System.out.println(method.showWhitReturn(1));//返回Integer
    }
}
